package com.seed.application.selector.impl;

import com.seed.application.Sa;
import com.seed.uaa.tenant.TenantConfiguration;
import com.seed.uaa.web.UaaConfiguration;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.type.AnnotationMetadata;

import java.util.ArrayList;
import java.util.List;

public class AppSeedSelector implements ImportSelector {
    @Override
    public String[] selectImports(AnnotationMetadata importingClassMetadata) {
        List<String> ret = new ArrayList<>();

        boolean enableTenant = Sa.getConfiguration().isEnableTenant();
        ret.add(UaaConfiguration.class.getName());
        if(enableTenant) ret.add(TenantConfiguration.class.getName());

        return ret.toArray(String[]::new);
    }
}
